	
	/******************************************************************************\
	|    Title:        	 Replication code for Globalization, Government            |
	|                    Popularity, and the Great Skill Divide     			   |
	|    Date:         	 September 2023                                            |
	\******************************************************************************/
	
	clear all
	set more off

	program main
		* *** Add required packages from SSC to this list ***
		local ssc_packages "gtools gcollapse ivreg2 ftools reghdfe estout pwcorr esttab coefplot unique ranktest"
		* *** Add required packages from SSC to this list ***

		if !missing("`ssc_packages'") {
			foreach pkg in `ssc_packages' {
			* install using ssc, but avoid re-installing if already present
				capture which `pkg'
				if _rc == 111 {                 
				   dis "Installing `pkg'"
				   quietly ssc install `pkg', replace
				   }
				 else {
				 	dis "Updating `pkg'"
					qui ado update `pkg'
				 }
			}
		}

	end

	main
	
	di "Installing frmttable"
	cap ado uninstall sg97_5
	net install sg97_5, from(http://www.stata-journal.com/software/sj12-4/)
	
	* Installing ivreghdfe from the repository as the latest version is not in Stata
	di "Installing ivreghdfe from the github repository"
	cap ado uninstall ivreghdfe
	net install ivreghdfe, from(https://raw.githubusercontent.com/sergiocorreia/ivreghdfe/master/src/)
	
